import React from 'react';
import { Button, message } from 'antd';
import ProForm, { ModalForm, ProFormText, ProFormTextArea } from '@ant-design/pro-form';
import { PlusOutlined } from '@ant-design/icons';
import { request } from 'umi';
import { api } from '@/global';
const waitTime = (time: number = 100) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(true);
    }, time);
  });
};

type propsType = {
  fileId: string;
  reload: any;
};

export default (props: propsType) => {
  return (
    <ModalForm<{
      name: string;
      company: string;
    }>
      title="打回"
      trigger={<a>打回</a>}
      autoFocusFirstInput
      modalProps={{
        onCancel: () => console.log('run'),
      }}
      onFinish={async (values) => {
        const r = await request(api.failApprovalFile, {
          method: 'POST',
          data: {
            fileId: props.fileId,
            cause: values?.cause,
          },
        });

        if (r.success) {
          message.success('打回成果');
          props.reload();
        } else {
          message.error('打回失败');
        }

        return true;
      }}
    >
      <ProFormTextArea width="xl" name="cause" label="打回理由" />
    </ModalForm>
  );
};
